package main

import "fmt"

type cat struct {
	name string
}
type dog struct {
	name string
}

func (c cat) speak() {
	fmt.Printf("%v：喵喵喵\n", c.name)
}
func (d *dog) speak() {
	fmt.Printf("%v：旺旺旺\n", d.name)
}

type speaker interface {
	speak()
}

// 场景：传入任意类型的参数，只是为了调用其speak方法
func da(x speaker) {
	x.speak()
}

func main() {
	var s speaker
	fmt.Println(s)

	d := &dog{
		name: "狗",
	}
	s = d
	s.speak()
	fmt.Println(s)

	c := &cat{name: "猫"}
	s = c
	s.speak()
	fmt.Println(s)
}
